package com.jdeng.service;

import com.jdeng.api.Goods;
import com.jdeng.api.GoodsService;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Method;
import org.springframework.beans.factory.annotation.Value;

@DubboService(timeout = 4000,
        parameters = {"hash.arguments", "0,1", "hash.nodes", "320"},
        methods = {@Method(name = "selectGoods", loadbalance = "consistenthash")})
public class GoodServiceImpl implements GoodsService {

    @Value("${server.name}")
    String sererName;

    @Override
    public Goods getGoods(Integer id) {
        return new Goods(id, sererName);
    }

    @Override
    public Goods selectGoods(Integer id, String name, String shortName) {
        System.out.println("server.name is " + sererName);
        return new Goods(id, name, shortName);
    }

    @Override
    public void insertGoods(Integer id) {
        System.out.println("server.name is " + id + " " + sererName);
    }
}
